/**
  ******************************************************************************
  * @file    GPIO/GPIO_IOToggle/stm32f4xx_it.c 
  * @author  MCD Application Team
  * @version V1.4.0
  * @date    04-August-2014
  * @brief   Main Interrupt Service Routines.
  *          This file provides template for all exceptions handler and 
  *          peripherals interrupt service routine.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_it.h"

/** @addtogroup STM32F4xx_StdPeriph_Examples
  * @{
  */

/** @addtogroup GPIO_IOToggle
  * @{
  */

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/******************************************************************************/
/*            Cortex-M4 Processor Exceptions Handlers                         */
/******************************************************************************/

/**
  * @brief   This function handles NMI exception.
  * @param  None
  * @retval None
  */
void NMI_Handler(void)
{
}

/**
  * @brief  This function handles Hard Fault exception.
  * @param  None
  * @retval None
  */
void HardFault_Handler(void)
{
  /* Go to infinite loop when Hard Fault exception occurs */
  while (1)
  {
  }
}

/**
  * @brief  This function handles Memory Manage exception.
  * @param  None
  * @retval None
  */
void MemManage_Handler(void)
{
  /* Go to infinite loop when Memory Manage exception occurs */
  while (1)
  {
  }
}

/**
  * @brief  This function handles Bus Fault exception.
  * @param  None
  * @retval None
  */
void BusFault_Handler(void)
{
  /* Go to infinite loop when Bus Fault exception occurs */
  while (1)
  {
  }
}

/**
  * @brief  This function handles Usage Fault exception.
  * @param  None
  * @retval None
  */
void UsageFault_Handler(void)
{
  /* Go to infinite loop when Usage Fault exception occurs */
  while (1)
  {
  }
}

/**
  * @brief  This function handles SVCall exception.
  * @param  None
  * @retval None
  */
//void SVC_Handler(void)
//{
//}

/**
  * @brief  This function handles Debug Monitor exception.
  * @param  None
  * @retval None
  */
void DebugMon_Handler(void)
{
}

/**
  * @brief  This function handles PendSVC exception.
  * @param  None
  * @retval None
  */
//void PendSV_Handler(void)
//{
//}

/**
  * @brief  This function handles SysTick Handler.
  * @param  None
  * @retval None
  */
//void SysTick_Handler(void)
//{
//}

/******************************************************************************/
/*                 STM32F4xx Peripherals Interrupt Handlers                   */
/*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
/*  available peripheral interrupt handler's name please refer to the startup */
/*  file (startup_stm32f40xx.s/startup_stm32f427x.s/startup_stm32f429x.s).    */
/******************************************************************************/

/**
  * @brief  This function handles PPP interrupt request.
  * @param  None
  * @retval None
  */
/*void PPP_IRQHandler(void)
{
}*/

/**
  * @}
  */ 

/**
  * @}
  */ 
#include "timer.h"
#include "drv_led.h"
#include "timer.h"
extern u8 times1;
extern u8 times2;
extern u8 times3;
extern u8 times4;

void EXTI4_IRQHandler(void)
{
	if(EXTI_GetITStatus(EXTI_Line4))//åˆ¤æ–­å¤–éƒ¨ä¸­æ–­çº¿
	{
		EXTI_ClearITPendingBit(EXTI_Line4);
		TIM_Cmd(TIM5, ENABLE);
		if(GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_4) == RESET)//æ¶ˆæŠ–
		{
			//GPIO_ToggleBits(GPIOE, GPIO_Pin_8);
			times1=1;
		}
	}
}
//#include "oled.h"
//#include "pwm.h"
//u8 LED1=0;
//u8 LED2=0,LEDSTATE=0;
//u8 BEEP=0,feng=0;
//extern u8 currentpage;

void EXTI9_5_IRQHandler(void)
{
	if(EXTI_GetITStatus(EXTI_Line5))//åˆ¤æ–­å¤–éƒ¨ä¸­æ–­çº¿
	{
		EXTI_ClearITPendingBit(EXTI_Line5);
		TIM_Cmd(TIM5, ENABLE);
		if(GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_5) == RESET)//æ¶ˆæŠ–
		{
			//GPIO_ToggleBits(GPIOE, GPIO_Pin_8);
			times2=1;

		}
	}

	if(EXTI_GetITStatus(EXTI_Line6))
	{
		EXTI_ClearITPendingBit(EXTI_Line6);
		TIM_Cmd(TIM5, ENABLE);
		if(GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_6) == RESET)//æ¶ˆæŠ–
		{
		//GPIO_ToggleBits(GPIOE, GPIO_Pin_8);
			times3=1;
		};
		
	}
}
void EXTI15_10_IRQHandler(void)
{
	if(EXTI_GetITStatus(EXTI_Line13))//åˆ¤æ–­å¤–éƒ¨ä¸­æ–­çº¿
	{
		EXTI_ClearITPendingBit(EXTI_Line13);
		TIM_Cmd(TIM5, ENABLE);
		if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_13) == RESET)//æ¶ˆæŠ–
		{
			//GPIO_ToggleBits(GPIOE, GPIO_Pin_8);
			times4=1;
		}
	}
}
#include "AD.h"
#include "DHT11.h"
//u8 temp_val,humi_val;
//u8 temp=temp_set,humi=humi_set;
//u8 temp_alarm=0,humi_alarm=0;
//u8 temp_use=0,humi_use=0;
//u8 beep_state=0,use_clear=0;//å‰ä¸€ä¸ªç”¨æ¥æŽ§åˆ¶beepæ–­æ–­ç»­ç»­çš„å«ï¼ŒåŽä¸€ä¸ªç”¨æ¥è¡¨ç¤ºæ“ä½œè€…å–æ¶ˆæŠ¥è­¦
#include "WIFI.h"
#include "string.h"
extern u8 get,temp_use,humi_use;

void TIM5_IRQHandler(void)
{
	if (TIM_GetITStatus(TIM5, TIM_IT_Update) != RESET) {  
		// æ¸…é™¤ä¸­æ–­æ ‡å¿—  
		TIM_ClearITPendingBit(TIM5, TIM_IT_Update);	
	 	if(get==1){
			if(strcmp((const char*)GET_BUF,"openled")==0){GPIO_ToggleBits(GPIOE, GPIO_Pin_8);}
			if(strcmp((const char*)GET_BUF,"beep")==0){TIM_SetCompare3(TIM2,0);humi_use=1;}
			if(strcmp((const char*)GET_BUF,"beepc")==0){TIM_SetCompare3(TIM2,300);humi_use=0;}
			if(strcmp((const char*)GET_BUF,"feng")==0){TIM_SetCompare2(TIM12,1000);temp_use=1;}
			if(strcmp((const char*)GET_BUF,"fengc")==0){TIM_SetCompare2(TIM12,0);temp_use=0;}
			if(strcmp((const char*)GET_BUF,"key1")==0){times1++;}
			if(strcmp((const char*)GET_BUF,"key2")==0){times2++;}
			if(strcmp((const char*)GET_BUF,"key3")==0){times3++;}
			if(strcmp((const char*)GET_BUF,"key4")==0){times4++;}
			memset((char*)GET_BUF,0,sizeof(GET_BUF));
		}
		// åœæ­¢å®šæ—¶å™¨  
		TIM_Cmd(TIM5, DISABLE); 
	}
		
}


/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
